<?php defined('SYSPATH') or die('No direct script access.');

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2020/07/14 18:34
 * Desc: 密码重置
 */
class Controller_Pc_Api_V2_Member_Find extends Controller_Pc_Api_v2_Base
{

    // 数据请求结果
    private $result;

    /**
     * 参数验证对象
     * @var Request_Api_V2_Member_Find
     */
    private $validation;

    /**
     * 服务
     * @var Service_Api_Member_Find
     */
    private $service;

    public function before()
    {
        parent::before();

        // 验证
        $this->validation = Request_Api_V2_Factory::create('member_find', $this->request_params);

        // 服务
        $this->service = new Service_Api_Member_Find();

        // 返回数据
        $this->result = array('status' => true, 'msg' => '操作成功', 'data' => array());
    }

    public function after()
    {
        $this->send_datagrams($this->client_info['id'], $this->result, $this->client_info['secret_key']);
    }

    //  找回密码第一步
    public function action_user_verify()
    {
        try {
            $this->validation->user_verify()->check();

            $this->result['data'] = $this->service->user_verify($this->request_params);
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

    // 重置密码
    public function action_reset_password()
    {
        try {
            $this->validation->reset_password()->check();

            $this->result['data'] = $this->service->reset_password($this->request_params);
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }
}
